# -*- coding: UTF-8 -*-
"""
@Project : FastTortoiseDemo
@File    : .py
@IDE     : PyCharm
@Author  : xuan
@Date    : 2023/12/29 11:42
"""
from typing import Union, List
from pydantic import BaseModel, Field
from datetime import datetime


class UserCreateSchema(BaseModel):
    """
    创建用户模型校验
    """
    username: str
    password: str


class UserLoginSchema(BaseModel):
    """
    用户登录模型校验
    """
    username: str
    password: str


class UserUpdateSchema(BaseModel):
    """
    用户更新模型校验
    """
    username: str
    password: str


class UserResponseDict(BaseModel):
    """用户返回字段"""
    id: int
    username: str = Field(title="张三")
    create_time: datetime = None
    update_time: datetime = None
    is_deleted: int


class UserResponse(BaseModel):
    message: Union[List[UserResponseDict], str]


class OneUserResponse(BaseModel):
    message: Union[List[UserResponseDict], str]


class UserData(BaseModel):
    id: str
    username: str
    is_deleted: int


class UserInDB(UserData):
    hashed_password: str


class UserOut(BaseModel):
    id: str
    username: str


class Token(BaseModel):
    access_token: str
    token_type: str


class TokenData(BaseModel):
    username: Union[str, None] = None
